<?php
function check_port($ip,$port) {
$conn = @fsockopen($ip, $port, $errno, $errstr, 0.2);
if ($conn) {
fclose($conn);
return true;
}
}

function server_report($ip) {
$report = array();
$svcs = array('21'=>'FTP',
'22'=>'SSH',
'25'=>'SMTP',
'80'=>'HTTP',
'110'=>'POP3',
'143'=>'IMAP',
'3306'=>'MySQL');
foreach ($svcs as $port=>$service) {
$report[$service] = check_port($ip,$port);
}
return $report;
}
for ($i=1;$i<=30;$i++){
$ip="203.6.148.".$i;
$report = server_report($ip);
?>
<table>
<tr>
<td>Service</td>
<td>Status <?php echo"ip= $ip;" ?></td>
</tr>
<tr>
<td>FTP</td>
<td><?php echo $report['FTP'] ? "<font color='green'>Online</font>" : "<font color='red'>Offline</font>"; ?></td>
</tr>
<tr>
<td>SSH</td>
<td><?php echo $report['SSH'] ? "<font color='green'>Online</font>" : "<font color='red'>Offline</font>"; ?></td>
</tr>
<tr>
<td>SMTP</td>
<td><?php echo $report['SMTP'] ? "<font color='green'>Online</font>" : "<font color='red'>Offline</font>"; ?></td>
</tr>
<tr>
<td>HTTP</td>
<td><?php echo $report['HTTP'] ? "<font color='green'>Online</font>" : "<font color='red'>Offline</font>"; ?></td>
</tr>
<tr>
<td>POP3</td>
<td><?php echo $report['POP3'] ? "<font color='green'>Online</font>" : "<font color='red'>Offline</font>"; ?></td>
</tr>
<tr>
<td>IMAP</td>
<td><?php echo $report['IMAP'] ? "<font color='green'>Online</font>" : "<font color='red'>Offline</font>"; ?></td>
</tr>
<tr>
<td>MySQL</td>
<td><?php echo $report['MySQL'] ? "<font color='green'>Online</font>" : "<font color='red'>Offline</font>"; ?></td>
</tr>
</table>
<?
}
?>